package com.cy.stone.system.adapter;

import com.cy.stone.common.base.AddGroup;
import com.cy.stone.common.base.EditGroup;
import com.cy.stone.framework.log.annotation.Log;
import com.cy.stone.framework.log.enums.BusinessType;
import com.cy.stone.system.application.DictTypeApi;
import com.cy.stone.system.domain.clientobject.dict.DictTypeCO;
import com.cy.stone.system.domain.dto.dict.DictTypeDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dictType/")
@RequiredArgsConstructor
@Tag(name = "字典类型服务适配器")
public class DictTypeController {

    private final DictTypeApi dictTypeApi;

    @PostMapping("list")
    @Operation(summary = "获取字典类型列表")
    public List<DictTypeDTO> list() {
        return dictTypeApi.list();
    }

    @PostMapping("addDictType")
    @Operation(summary = "新增字典类型")
    @Log(title = "新增字典类型", businessType = BusinessType.INSERT, isSaveResponseData = false)
    public void addDictType(@RequestBody @Validated(AddGroup.class) DictTypeCO dictTypeCO) {
        dictTypeApi.addDictType(dictTypeCO);
    }

    @PostMapping("editDictType")
    @Operation(summary = "编辑字典类型")
    @Log(title = "编辑字典类型", businessType = BusinessType.UPDATE, isSaveResponseData = false)
    public void editDictType(@RequestBody @Validated(EditGroup.class) DictTypeCO dictTypeCO) {
        dictTypeApi.editDictType(dictTypeCO);
    }
}
